      subroutine cbalance (laisun, laisha,psnsun, psnsha, dc6, FCVEG,dt,npp, c6, litter_in, dnpp) 
 ! calculating the components of the C balance
 
      use INMSOIL_NUMPARAMS, only : &
     & ML, MS
      use CBALANCE_CONST
!      INCLUDE 'soil.inc'
      !input
     REAL (KIND=8) laisun(nv2)
	 REAL (KIND=8) laisha(nv2)
	 REAL (KIND=8) psnsun(nv2)
	 REAL (KIND=8) psnsha (nv2)
	 REAL (KIND=8)dc6(nv2) ! biomass of a vegetation type kgCm-2s-1 also output
	 REAL (KIND=8) FCVEG(nv2) ! proportion of a gridcell covered by this veg type from ECOCLIMAP
	 REAL (KIND=8) dt !model time step in s

         !output
	 REAL (KIND=8) npp  !CO2 flux of C to vegetation (psn-plant resp)  kgCm-2s-1
      REAL (KIND=8)c6 !total plant biomass  kgCm-2
      REAL (KIND=8) litter_in(nv2) !litter input from a vegatation type  kgCm-2s-1
      REAL (KIND=8) dnpp(nv2) !npp from a vegetation type kgCm-2s-1

    !local variables 
     REAL (KIND=8) fpsn(nv2) !photosynthesis (umol co2 /m**2/ s)
     REAL (KIND=8) CUE
     REAL (KIND=8) yrs
     yrs=86400.*365.25
     CUE=0.54 !carbon use efficiency 0.46*psn=plant respiration

         c6=0.0
         npp=0.0
         do k=1, nv2
         write(*,*)'b', a15(k)
      !     a15(k)=a15(k)/100.
           write(*,*)'a', a15(k)
           fpsn(k)=(psnsun(k)*laisun(k)+psnsha(k)*laisha(k))
           dnpp(k)=(CUE*fpsn(k)*12.e-9)*FCVEG(k)
           litter_in(k)=a15(k)*dc6(k)/(100.*yrs)
            !write(*,*)'before', dc6(k),a15(k),yrs
           dc6(k)=dc6(k)+(dnpp(k)-litter_in(k))*dt
          ! write(*,*) 'after',k, dnpp(k), litter_in(k) 
           c6=c6+dc6(k)
           npp=npp+dnpp(k)
         end do
        end 
